<%@ page import="com.andy.sun.services.TaskService" %>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <!-- 上述3个meta标签*必须*放在最前面，任何其他内容都*必须*跟随其后！ -->
    <link href="css/bootstrap.min.css" rel="stylesheet">
    <script src="js/jquery-3.5.1.js"></script>
    <script src="js/bootstrap.min.js"></script>
    <link rel="icon" href="images/12.ico">
    <title>任务管理登录</title>
    <style>
        *{
            margin: 0;
            padding: 0;
            box-sizing: border-box;
        }
        body{background: linear-gradient(#d973f1, #ffb8e8);}
        .myinner{
            min-height: 100vh;
            display: flex;
            margin-top: -20px;
            justify-content: center;
            align-items: center;
            overflow: hidden;
        }
        .ring{
            position: relative;
            display: block;
            width: 500px;
            height: 500px;
            display: flex;
            justify-content: center;
            align-items: center;
        }
        .ring i{
            position: absolute;
            border: 2px solid #f454da;
            inset: 0;
            transition: all 0.5s;
        }
        .ring i:nth-child(1){
            border-radius: 38% 62% 63% 37% / 41% 44% 56% 59%;
            animation: animate 6s linear infinite;
        }
        .ring i:nth-child(2){
            border-radius: 41% 44% 56% 59% / 38% 62% 63% 37%;
            animation: animate 4s linear infinite;
        }
        .ring i:nth-child(3){
            border-radius: 41% 44% 56% 59% / 38% 62% 63% 37%;
            animation: animate 10s linear infinite reverse;
        }
        .ring:hover i{
            border: 6px solid var(--clr);
            filter: drop-shadow(0 0 20px var(--clr));
        }
        .login{
            position: absolute;
            width: 300px;
            height: 100%;
            display: flex;
            flex-direction: column;
            justify-content: center;
            align-items: center;
            gap: 20px;
        }
        .login h2{
            color: #fff;
            font-size: 32px;
            letter-spacing: 16px;
            text-indent: 16px;
            margin-bottom: 16px;
        }
        .login .ipt-box{
            position: relative;
            width: 100%;
        }
        .login .ipt-box input{
            position: relative;
            width: 100%;
            padding: 12px 20px;
            background-color: transparent;
            border: 2px solid #fff;
            border-radius: 40px;
            font-size: 18px;
            color: #fff;
            box-shadow: none;
            outline: none;
            margin-top: 10px;
        }
        .login .ipt-box input[type="submit"]{
            width: 100%;
            background: linear-gradient(45deg,#ff357a, #9900ff);
            border: none;
            cursor: pointer;
        }
        .login .ipt-box input::placeholder{
            color: rgba(255,255,255,0.75);
        }
        .login .links{
            position: relative;
            width: 100%;
            display: flex;
            justify-content: space-between;
            align-items: center;
            padding: 0 20px;
        }
        .login .links a{
            color: #fff;
            text-decoration: none;
        }
        @keyframes animate {
            0%{
                transform: rotate(0);
            }
            100%{
                transform: rotate(360deg);
            }
        }
        #footer a{
            color: #e1df9e;
        }
        @media (max-width: 1023px){
            #footer{
                font-size: 9px;
            }
        }

    </style>
</head>
<body>
<%
    //进入登录页面后,就要清空登录用户信息,并且销毁所有session
    session.invalidate();

    // 检查是否有 用户信息是否全部 存在于 Cookie 中
    Cookie[] cookies = request.getCookies();
    String uname = "";
    String upwd = "";
    int uid = 0;
    if (cookies != null) {
        for (Cookie cookie : cookies) {
            if ("task_uname".equals(cookie.getName())) {
                uname = cookie.getValue();
            }
            if ("task_upwd".equals(cookie.getName())) {
                upwd = cookie.getValue();
            }
            if ("task_uid".equals(cookie.getName())) {
                uid = cookie.getValue()!=""?Integer.parseInt(cookie.getValue()):0;
            }
        }
        if (!uname.isEmpty()&&!upwd.isEmpty()&&uid!=0) {
            request.getRequestDispatcher("LoginServlet?cokie_uid="+uid+"&name="+uname+"&pwd="+upwd).forward(request, response);
        }
    }
%>

<%--    引入导航--%>
<nav class="navbar navbar-inverse">
    <div class="container-fluid">
        <!-- Brand and toggle get grouped for better mobile display -->
        <div class="navbar-header">
            <button type="button" class="navbar-toggle collapsed" data-toggle="collapse"
                    data-target="#bs-example-navbar-collapse-1" aria-expanded="false">
                <span class="sr-only">切换导航</span>
                <span class="icon-bar"></span>
                <span class="icon-bar"></span>
                <span class="icon-bar"></span>
            </button>
            <a class="navbar-brand" href="getTask.jsp" target="_parent">首页·计划管理</a>
        </div>

        <div class="collapse navbar-collapse" id="bs-example-navbar-collapse-1">
            <ul class="nav navbar-nav">
                <li><a target="_parent" href="TaskLineServlet">任务成就</a></li>
                <li><a target="_parent" href="ProSpectServlet?what=query">布局·规划</a></li>
                <li><a target="_parent" href="URLServlet?what=query">重要网址</a></li>
                <li><a target="_parent" href="NoteServlet?what=query">重要记事</a></li>
                <li><a target="_parent" href="mottos.jsp">感悟·格言</a></li>
                <li><a target="_parent" href="bookNotes.jsp">读书笔记</a></li>
            </ul>
            <form class="navbar-form navbar-left" role="search">
                <div class="form-group">
                    <input type="text" class="form-control" placeholder="Search">
                </div>
                <button type="submit" class="btn btn-default">搜索</button>
            </form>
            <ul class="nav navbar-nav navbar-right">
                <li><a target="_parent" href="login.jsp">${uname==null?"登录":uname}</a></li>
                |
                <li><a target="_parent" href="regist.jsp">注册</a></li>
                <li><a target="_parent" href="#">会员中心</a></li>
                <li><a target="_parent" href="Contact_us.jsp">联系我们</a></li>

            </ul>
        </div>
    </div>
</nav>
<div class="myinner">
    <div class="ring">
        <i style="--clr:#ffcaef;"></i>
        <i style="--clr:#ff7cd8;"></i>
        <i style="--clr:#f454da;"></i>
        <div class="login">
            <h2>登录</h2>
            <h4>${error}</h4>
            <form action="LoginServlet" method="post">
                <div class="ipt-box">
                    <input type="text" class="username" name="name" value="${user.uName}" placeholder="账号">
                </div>
                <div class="ipt-box">
                    <input type="password" class="password" name="pwd" value="${user.uPwd}" placeholder="密码">
                </div>
                <div class="ipt-box">
                    <input type="submit" value="登录">
                </div>
                <br>
                <div class="links">
                    <a href="updatePwd.jsp" id="forget">忘记密码 / 修改密码</a>
                    <a href="regist.jsp">注册</a>
                </div>
            </form>
        </div>
    </div>
</div>
<div id="update-pwd" class="modal fade" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
    <div class="modal-dialog">
        <div class="modal-content">
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal" aria-hidden="true">
                    &times;
                </button>
                <h4 class="modal-title">
                    修改密码
                </h4>
            </div>
            <div class="modal-body">
                <form action="UpdatePwdServlet" method="post">
                    <div class="ipt-box">
                        <input type="text" class="username" name="name" value="${user.uName}" placeholder="账号">
                    </div>
                    <div class="ipt-box">
                        <input type="password" class="password" name="oldpwd" placeholder="旧密码">
                    </div>
                    <div class="ipt-box">
                        <input type="password" class="password" name="newpwd" placeholder="新密码">
                    </div>
                    <div class="ipt-box">
                        <input type="password" class="password" name="newpwd2" placeholder="确认新密码">
                    </div>
                    <div class="ipt-box">
                        <input type="submit" value="提交">
                    </div>
                </form>
            </div>
        </div>
    </div>
</div>

<footer  id="footer" class="navbar navbar-fixed-bottom navbar-inverse navbar-brand  text-center"
         style="color: yellow; font-size: 14px">
    <a target="_blank" href="https://beian.miit.gov.cn">京ICP备2024085356号</a> | &nbsp;
    <a href="https://beian.mps.gov.cn/#/query/webSearch?code=11011402054364"
       rel="noreferrer" target="_blank">京公网安备11011402054364</a>
    | <a target="_self" href="#">&copy; 2024 凡尘先生 </a>
</footer>
</body>
<script>
    $("form").submit(function () {
        let $name = $(".username").val();
        let $pwd = $(".password").val();
        if ($name === "") {
            alert("用户名不能为空");
            return false;
        }
        if ($pwd === "") {
            alert("密码不能为空");
            return false;
        }
        return true;
    })

</script>
</html>